home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-13 | 23.4 KB | 762 lines | [TEXT/KAHL] |
- //------------------------- © 1994 - 1995 by James G. Stout ------------------------
- // File : cdefVSlider.c
- // Date : April 6, 1994
- // Author : Jim Stout
- // :
- // Purpose : A slider CDEF modeled after the one in the Sound Control panel
- // :
- // : see cdefVSlider.h for more detail and variation codes
- // :
- // : If you find a use for this, I'd love to know about it. Bug reports
- // : are always interesting.
- // :
- // : Internet : JimS@WRQ.COM(work hours, PST)
- // : AppleLink : WRQ (daily)
- // : CompuServe : 73240,2052 (weekly or so)
- // : AOL : JasG (weekly or so)
- // : eWorld : Jim Stout (weekly or so)
- //----------------------------------------------------------------------------------
- //#define _DEBUGCDEF // comment this to build CDEF
-
- #include "fatCDEF.h"
-
- #include <Controls.h>
- #include <Fonts.h>
- #include <GestaltEqu.h>
- #include <Memory.h>
- #include <QDOffscreen.h>
- #include <ToolUtils.h>
- #include <Types.h>
- #include <Windows.h>
-
-
- #include "grayCDEF.h"
- #include "colorCDEF.h"
- #include "miscCDEF.h"
- #include "qdCDEF.h"
-
- #include "cdefVslider.h"
-
- #ifdef _DEBUGCDEF
- pascal long CDmain (short, ControlHandle, short, long);
-
- pascal long CDmain (short varCode, ControlHandle theCtl, short message, long param)
- #else
-
- //==================================================================================
- // CDEF entry point
- //==================================================================================
- pascal long main (short varCode, ControlHandle theCtl, short message, long param)
- #endif
- {
- long ret = 0L;
- SignedByte cState, dState;
-
- #include "fatEntry.c"
-
- cState = HGetState((Handle)theCtl);
- HLock((Handle)theCtl);
- if((**theCtl).contrlData) {
- dState = HGetState((**theCtl).contrlData);
- HLock((**theCtl).contrlData);
- }
-
- switch(message) {
- case initCntl:
- doInit(theCtl);
- if((**theCtl).contrlData) {
- dState = HGetState((**theCtl).contrlData);
- HLock((**theCtl).contrlData);
- }
- break;
- case dispCntl:
- doDisp(theCtl);
- break;
- case drawCntl:
- if ((**theCtl).contrlVis != 0 &&
- ((WindowPeek)(**theCtl).contrlOwner)->visible) {
- doDraw(theCtl, varCode);
- }
- break;
- case testCntl:
- ret = doTest (theCtl, varCode, param);
- break;
- case calcCRgns:
- RectRgn((RgnHandle)(param & 0x7fffffffL), &(**theCtl).contrlRect);
- break;
- case calcCntlRgn:
- case calcThumbRgn:
- RectRgn((RgnHandle)(param), &(**theCtl).contrlRect);
- break;
- }
-
- if((**theCtl).contrlData)
- HSetState((**theCtl).contrlData, dState);
- HSetState((Handle)theCtl, cState);
-
-
- #include "fatExit.c"
-
- return (ret);
- }
-
- //==================================================================================
- // Initialize our control data
- //==================================================================================
-
- static void doInit (ControlHandle theCtl)
- {
- short scaleSize;
- Rect scaleRect;
- CDEFHandle hCDEF;
-
- //----------------------------------------------------------------------------------
- // check for a reasonably sized scale
- //----------------------------------------------------------------------------------
-
- scaleSize = (**theCtl).contrlRfCon;
- if(scaleSize < 2 || scaleSize > 20) // must be at least 2 units high
- scaleSize = 7; // … 7 is like the Sound Control panel
-
- //----------------------------------------------------------------------------------
- // force the scale rect to the size we want, it'll be clipped to the control Rect
- //----------------------------------------------------------------------------------
-
- scaleRect = (**theCtl).contrlRect;
- scaleRect.right = scaleRect.left + 42;
- scaleRect.bottom = scaleRect.top + scaleSize*12+21;
-
- //----------------------------------------------------------------------------------
- // force the min & max as well
- //----------------------------------------------------------------------------------
-
- (**theCtl).contrlMin = 0;
- (**theCtl).contrlMax = scaleSize*12; // number of pixels in scale
- (**theCtl).contrlRfCon = 0;
-
- hCDEF = (CDEFHandle)NewHandle(sizeof(CDEFData));
- if(hCDEF) {
- (**hCDEF).pDepth = 1; // filled in in doDraw()
- (**hCDEF).offPort = 0;
- (**hCDEF).scaleSize = scaleSize;
- (**hCDEF).scaleRect = scaleRect;
- (**hCDEF).qdVers = getQDVers();
-
- (**theCtl).contrlData = (Handle)hCDEF;
- }
- else
- (**theCtl).contrlData = 0;
- }
-
- //==================================================================================
- // Get rid of our control data
- //==================================================================================
-
- static void doDisp (ControlHandle theCtl)
- {
- CDEFHandle hCDEF;
- BitMap *theBits;
-
- hCDEF = (CDEFHandle)(**theCtl).contrlData;
- if(hCDEF) {
- if((**hCDEF).offPort) {
- if(((**hCDEF).offPort->portVersion & 0x8000) != 0) { // offPort is GWorld
- DisposeGWorld((**hCDEF).offPort);
- }
- else { // offport is bitmap
- theBits = &((GrafPtr)(**hCDEF).offPort)->portBits;
- DisposePtr((*theBits).baseAddr);
- ClosePort((GrafPtr)(**hCDEF).offPort);
- DisposePtr((Ptr)(**hCDEF).offPort);
- }
- }
-
- HUnlock((Handle)hCDEF);
- DisposeHandle((Handle)hCDEF);
- (**theCtl).contrlData = 0;
- }
- }
-
- //==================================================================================
- // Test to see if the mouse was pressed in the control thumb and
- // drag accordingly
- //==================================================================================
-
- static long doTest (ControlHandle theCtl, short varCode, long param)
- {
- Rect rThumb, rScale;
- Point p;
- long ret=0,secs;
- short partCode;
- CDEFHandle hCDEF;
-
- hCDEF = (CDEFHandle)(**theCtl).contrlData;
- if(!hCDEF)
- return(ret);
-
- partCode = (**theCtl).contrlHilite;
-
- rScale = (**hCDEF).scaleRect;
-
- //----------------------------------------------------------------------------------
- // get the thumb rect, calculated from control value
- //----------------------------------------------------------------------------------
- getThumbRect(theCtl, &rThumb, &rScale);
-
- rScale.left+=17; // inset for active area
- InsetRect(&rScale,8,5);
-
- p.h = LoWord(param);
- p.v = HiWord(param);
-
- if(PtInRect(p, &rThumb)) { // click in thumb?
- ret = 1;
- dragThumb(theCtl, varCode, param);
- }
- else
- if(PtInRect(p, &rScale)) { // click in scale?
- if(p.v < rThumb.bottom)
- ret = 2; // decrease
- else
- if(p.v > rThumb.top)
- ret = 3; // increase
-
- if(partCode == ret) {
- scaleClick(theCtl, varCode, (short)ret);
- Delay(6L, & secs);
- }
- }
- return(ret);
- }
-
- //==================================================================================
- // Respond to a mouse down in our "thumb", track the mouse to reposition the thumb,
- // set a new control value and call the actionProc (if any).
- //==================================================================================
- static void dragThumb (ControlHandle theCtl, short varCode, long param)
- {
- short units,newVal,snap,maxDrag,minDrag;
- Rect rThumb, rScale;
- Point p,oldPt;
-
- rScale = (**(CDEFHandle)(**theCtl).contrlData).scaleRect;
- getThumbRect(theCtl, &rThumb, &rScale);
-
- units = ((rScale.bottom-rScale.top)-21)/12;
- p.h = LoWord(param);
- p.v = oldPt.v = HiWord(param);
-
- if(PtInRect(p, &rThumb)) {
- maxDrag = rScale.bottom - 4 - (rThumb.bottom - p.v);
- minDrag = rScale.top + 4 + (p.v - rThumb.top);
-
- while (StillDown()) {
- if(oldPt.v != p.v) { // mouse moved
- OffsetRect(&rThumb, 0, (p.v-oldPt.v)); // move the thumb
- if(rThumb.top < rScale.top+5) // pin to top of scale
- OffsetRect(&rThumb, 0, rScale.top - rThumb.top+5);
- else
- if(rThumb.bottom > rScale.bottom-5) // pin to bottom of scale
- OffsetRect(&rThumb, 0, rScale.bottom - rThumb.bottom-5);
-
- newVal = (rScale.top - rThumb.top)+units*12+5;
- if(newVal != (**theCtl).contrlValue) {
- (**theCtl).contrlValue = newVal;
- doDraw(theCtl, varCode);
- if((**theCtl).contrlAction != nil)
- CallControlActionProc((**theCtl).contrlAction,
- theCtl, 1);
- }
- if(p.v > minDrag && p.v < maxDrag) // track move
- oldPt.v = p.v;
- }
- GetMouse(&p);
- }
- }
-
- //----------------------------------------------------------------------------------
- // adjust the control value & redraw if necessary
- //----------------------------------------------------------------------------------
-
- if(!(varCode & thumbNoSnap)) {
- snap = (rThumb.top-rScale.top-5)%12;
- if(snap) {
- if(snap >= 7)
- OffsetRect(&rThumb, 0, 12-snap);
- else
- OffsetRect(&rThumb, 0, -snap);
- }
- }
- (**theCtl).contrlValue = (rScale.top - rThumb.top)+units*12+5;
- doDraw(theCtl, varCode);
- if((**theCtl).contrlAction != nil)
- CallControlActionProc((**theCtl).contrlAction, theCtl, 1);
- }
-
- //==================================================================================
- // Adjust the control after detecting a click in the scale instead of the thumb -
- // set a new control value and call the actionProc (if any).
- //==================================================================================
- static void scaleClick (ControlHandle theCtl, short varCode,
- short partCode)
- {
- Rect rThumb, rScale;
- short incr,newVal,units;
-
- rScale = (**(CDEFHandle)(**theCtl).contrlData).scaleRect;
- getThumbRect(theCtl, &rThumb, &rScale);
-
- units = ((rScale.bottom-rScale.top)-21)/12;
- if(varCode & thumbNoSnap)
- incr = 1;
- else
- incr = 12;
-
- if(partCode == 2) {
- OffsetRect(&rThumb, 0, -incr);
- }
- else
- if(partCode == 3) {
- OffsetRect(&rThumb, 0, incr);
- }
-
- if(rThumb.top < rScale.top+5) // pin to top of scale
- OffsetRect(&rThumb, 0, rScale.top - rThumb.top+5);
- else
- if(rThumb.bottom > rScale.bottom-5) // pin to bottom of scale
- OffsetRect(&rThumb, 0, rScale.bottom - rThumb.bottom-5);
-
- newVal = (rScale.top - rThumb.top)+units*12+5;
-
- if(newVal != (**theCtl).contrlValue) {
- (**theCtl).contrlValue = newVal;
- doDraw(theCtl, varCode);
- if((**theCtl).contrlAction != nil)
- CallControlActionProc((**theCtl).contrlAction, theCtl, partCode);
- }
- }
-
- //==================================================================================
- // Calculate the thumb location from the control value
- //==================================================================================
-
- static void getThumbRect(ControlHandle theCtl, Rect *rThumb, Rect *rScale)
- {
- short v;
-
- SetRect(rThumb, 0, 0, 23, 11);
- v = (rScale)->bottom - 16 - (**theCtl).contrlValue;
- OffsetRect(rThumb, (rScale)->left+18,v);
- }
-
- //==================================================================================
- // Draw both the scale and thumb into one bitmap
- //==================================================================================
-
- Boolean drawParts (ControlHandle theCtl, short varCode, Rect *rThumb)
- {
- Rect rScale, r;
- Boolean inColor = false, haveGray = false;
- RGBColor saveFore, saveBack, grayColor, tingeColor, fillColor;
- RGBColor scaleColor = {56797, 56797, 56797};
- short h,v,inx;
- char c,c1;
- CDEFHandle hCDEF;
-
- hCDEF = (CDEFHandle)(**theCtl).contrlData; // already locked
- if(hCDEF) {
- //----------------------------------------------------------------------------------
- // set up our drawing rects
- //----------------------------------------------------------------------------------
-
- SetRect(&rScale, 0, 0, 42, (**hCDEF).scaleSize*12+21);
- r = rScale;
-
- //----------------------------------------------------------------------------------
- // Set colors - either cFrameColor or grayed version of cFrameColor if inactive
- //----------------------------------------------------------------------------------
-
- if((**hCDEF).pDepth > 2) {
- inColor = true;
- setPartColor(theCtl, cFrameColor, true);
- }
-
- if((**theCtl).contrlHilite == 0xFF) { // inactive control
- if(inColor) { // try to draw it in
- haveGray = getGray(&grayColor); // gray
- if(haveGray)
- RGBForeColor(&grayColor);
- }
- }
-
- if(inColor)
- saveColors(&saveFore, &saveBack); // saveFore may be gray...
-
- //----------------------------------------------------------------------------------
- // draw the scale into this offport
- //----------------------------------------------------------------------------------
-
- r.left+=23; // rect for the scale
- r.right-=6;
- ForeColor(whiteColor); // make it white
- PaintRoundRect(&r, 14, 10);
-
- if(inColor)
- RGBForeColor(&saveFore);
- else
- ForeColor(blackColor);
- BackColor(whiteColor);
-
- FrameRoundRect(&r, 14, 10); // frame outer rect
- InsetRect(&r, 2, 2); // now fill inner rect
-
- if(!(varCode & scaleNoFill)) {
- if(inColor) {
- setPartColor(theCtl, cBodyColor, true);
- GetForeColor(&fillColor);
- if(fillColor.red == 65535 &&
- fillColor.green == 65535 &&
- fillColor.blue == 65535) {
- ForeColor(blackColor);
- }
- if(haveGray) { // must be inactive
- if(getGray(&fillColor)) {
- RGBForeColor(&fillColor);
- }
- }
- }
- PenPat( (ConstPatternParam) "\xAA\x55\xAA\x55\xAA\x55\xAA\x55");
- PaintRoundRect(&r, 11, 9);
- PenPat( (ConstPatternParam) "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF");
- }
- if(inColor)
- RGBForeColor(&saveFore);
- else
- ForeColor(blackColor);
- FrameRoundRect(&r, 11, 9); // frame inner rect
-
- //----------------------------------------------------------------------------------
- // erase the corners of the inner round rect - the hard way
- //----------------------------------------------------------------------------------
-
- ForeColor(whiteColor);
- MoveTo(r.left+2, r.top);
- Line(0, 0);
- Move(4, 0);
- Line(0, 0);
- MoveTo(r.left+2, r.bottom-1);
- Line(0, 0);
- Move(4, 0);
- Line(0, 0);
-
- //----------------------------------------------------------------------------------
- // draw tick marks for scale
- //----------------------------------------------------------------------------------
- if(inColor) {
- RGBBackColor(&saveBack);
- setPartColor(theCtl, cTextColor, true);
- if(haveGray) { // inactive
- if(getGray(&grayColor))
- RGBForeColor(&grayColor);
- }
- }
- else
- ForeColor(blackColor);
-
- if(!(varCode & scaleBlank)) {
- MoveTo(r.left - 8, r.bottom - 9);
- for(inx = 0; inx<=(**hCDEF).scaleSize; inx++) {
- Line(3, 0);
- Move(-3, -12);
- }
-
- //----------------------------------------------------------------------------------
- // draw digits next to tick marks
- //----------------------------------------------------------------------------------
-
- TextFont(geneva);
- TextSize(9);
- v = r.bottom-4;
- h = r.left-18;
- c = c1 = '0';
- for(inx=0;inx<=(**hCDEF).scaleSize;inx++) {
- if(!(inx%10) && inx) {
- c = '0';
- c1++;
- }
- MoveTo (h, v);
- DrawChar(c);
- if(inx>9) {
- h-=6;
- MoveTo(h,v);
- DrawChar(c1);
- h+=6;
- }
- v-=12;
- c++;
- }
- }
-
- //----------------------------------------------------------------------------------
- // Draw 3D version of scale
- //----------------------------------------------------------------------------------
-
- if(varCode & ctl3D && inColor) {
- RGBForeColor(&scaleColor);
- RGBBackColor(&saveBack);
-
- //----------------------------------------------------------------------------------
- // fill center of scale with light gray
- //----------------------------------------------------------------------------------
-
- rScale.left+=17;
- InsetRect(&rScale,9,4);
- SetRect(&r, rScale.left+2,rScale.top-1,
- rScale.right-2,rScale.top+1);
- PaintRect(&r);
- SetRect(&r, rScale.left+2,rScale.bottom-1,
- rScale.right-2,rScale.bottom+1);
- PaintRect(&r);
- PaintRect(&rScale);
-
- //----------------------------------------------------------------------------------
- // draw 3D shadow along bottom & right
- //----------------------------------------------------------------------------------
-
- setPartColor(theCtl, cTingeLight, true);
- GetForeColor(&tingeColor);
- tingeColor.red-=13107;
- tingeColor.green-=13107;
- tingeColor.blue-=13107;
- RGBForeColor(&tingeColor);
- MoveTo(rScale.left+2, rScale.bottom);
- Line(2,0);
- Line(0,-1);
- Line(2,0);
- LineTo(rScale.right-1, rScale.top);
- }
-
- //----------------------------------------------------------------------------------
- // draw the Thumb into the offPort
- //----------------------------------------------------------------------------------
-
- ForeColor(whiteColor); // thumb defaults to
- PaintRoundRect(rThumb, 7, 11); // white background
- if(inColor)
- RGBForeColor(&saveFore); // with cFrameColor
- else
- ForeColor(blackColor);
- FrameRoundRect(rThumb, 7, 11);
-
- MoveTo(rThumb->left+1, rThumb->top+2);
- Line(19, 0);
- MoveTo(rThumb->left+1, rThumb->bottom-3);
- Line(19, 0);
-
- //----------------------------------------------------------------------------------
- // Draw 3D version of thumb
- //----------------------------------------------------------------------------------
-
- if(varCode & ctl3D && inColor) {
- RGBForeColor(&scaleColor);
- InsetRect(rThumb, 1, 3);
- PaintRect(rThumb);
- MoveTo((*rThumb).left+1, (*rThumb).top-2);
- LineTo((*rThumb).right-2, (*rThumb).top-2);
- MoveTo((*rThumb).left+1, (*rThumb).bottom+1);
- LineTo((*rThumb).right-2, (*rThumb).bottom+1);
-
- //----------------------------------------------------------------------------------
- // draw the 3D shadow in a grayed cTingeColor
- //----------------------------------------------------------------------------------
-
- RGBForeColor(&tingeColor);
- MoveTo((*rThumb).left, (*rThumb).bottom-1);
- LineTo((*rThumb).right-1, (*rThumb).bottom-1);
- LineTo((*rThumb).right-1, (*rThumb).top);
- MoveTo((*rThumb).right-2, (*rThumb).bottom-2);
- LineTo((*rThumb).right-2, (*rThumb).bottom-2);
- }
- else { // colorize center part
- if(inColor) { // of thumb
- ForeColor(whiteColor);
- setPartColor(theCtl, cThumbColor, true);
- InsetRect(rThumb, 1, 3);
- PaintRect(rThumb);
- }
- }
- }
- return(haveGray);
- }
-
- //==================================================================================
- // Draw the control, it is made up from the scale bitmap and the thumb bitmap
- // which are assembled into an offscreen bitmap in "drawParts". Now, we blit it
- // to our onscreen port.
- //==================================================================================
-
- static void doDraw (ControlHandle theCtl, short varCode)
- {
- Rect offRect, rThumb, rScale;
- RgnHandle saveClip, newClip;
- BitMap *offBits;
- PixMapHandle pmHdl;
- CGrafPtr savePort;
- GDHandle saveGDev;
- PenState savePen;
- Boolean inactive = false, haveGray = false, inColor = false, haveGW = false;
- RGBColor saveFore,saveBack;
- CDEFHandle hCDEF;
-
- hCDEF = (CDEFHandle)(**theCtl).contrlData; // already locked
- if(hCDEF) {
-
- //----------------------------------------------------------------------------------
- // If control has been moved we need to update our rect
- //----------------------------------------------------------------------------------
-
- rScale = (**theCtl).contrlRect;
- rScale.right = rScale.left + 42;
- rScale.bottom = rScale.top + (**hCDEF).scaleSize*12+21;
-
- (**hCDEF).scaleRect = rScale;
- (**theCtl).contrlData = (Handle)hCDEF;
-
- //----------------------------------------------------------------------------------
- // Create or update our GWorld
- //----------------------------------------------------------------------------------
-
- (**hCDEF).pDepth = getOff(&(**hCDEF).offPort, &(**theCtl).contrlRect);
-
- if((**hCDEF).pDepth == 0) // oh… oh…
- return;
-
- if(((**hCDEF).offPort->portVersion & 0x8000) != 0) {
- haveGW = true; // have a GWorld
- pmHdl = getLockedPixels(&(**hCDEF).offPort, (**hCDEF).qdVers);
- if(!pmHdl)
- return; // nuts…
- }
-
- //----------------------------------------------------------------------------------
- // Do the clip region properly. Thanks Ari!
- //----------------------------------------------------------------------------------
-
- saveClip = NewRgn();
- GetClip(saveClip);
-
- newClip = NewRgn();
- RectRgn(newClip, &(**theCtl).contrlRect);
- SectRgn(saveClip, newClip, newClip);
-
- if(EmptyRgn(newClip)) { // if empty, don't waste
- DisposeRgn(saveClip); // time drawing...
- DisposeRgn(newClip);
- return;
- }
-
- SetClip(newClip);
- //----------------------------------------------------------------------------------
- // Calculate size for offRect (scale) & position the thumb rect
- //----------------------------------------------------------------------------------
-
- SetRect(&offRect, 0, 0, 42, (**hCDEF).scaleSize*12+21);
- rScale = (**hCDEF).scaleRect;
-
- SetRect(&rThumb, 0, 0, 23, 11);
- OffsetRect(&rThumb, 18, offRect.bottom - 16 - (**theCtl).contrlValue);
-
- //----------------------------------------------------------------------------------
- // Initialize and set for drawing into offScreen port
- //----------------------------------------------------------------------------------
-
- if((**theCtl).contrlHilite == 0xFF) // inactive control
- inactive = true;
-
- if((**hCDEF).pDepth > 2) { // save onscreen
- inColor = true; // colors
- saveColors(&saveFore, &saveBack);
- }
-
- if(haveGW) { // we have a pixMap
- GetGWorld(&savePort, &saveGDev);
- SetGWorld((**hCDEF).offPort, nil);
- offBits = (BitMap *)*pmHdl;
- if((**(*savePort).bkPixPat).patType != 0 &&
- (savePort->portVersion & 0x8000) != 0)
- BackPixPat((*savePort).bkPixPat);
- }
- else { // we have a bitMap
- GetPort((GrafPtr*)&savePort);
- SetPort((GrafPtr)(**hCDEF).offPort);
- offBits = (BitMap *)&((GrafPtr)(**hCDEF).offPort)->portBits;
- }
-
- if(inColor) { // onscreen colors in
- RGBForeColor(&saveFore); // offscreen port
- RGBBackColor(&saveBack);
- }
-
- //----------------------------------------------------------------------------------
- // Erase background of offscreen port - pay attention to origin so patterned
- // backgrounds are aligned
- //----------------------------------------------------------------------------------
-
- SetOrigin((**theCtl).contrlRect.left, (**theCtl).contrlRect.top);
- EraseRect(&(**theCtl).contrlRect);
- SetOrigin(0,0);
-
- //----------------------------------------------------------------------------------
- // draw the control parts into the offscreen port
- //----------------------------------------------------------------------------------
-
- haveGray = drawParts (theCtl, varCode, &rThumb);
-
- //----------------------------------------------------------------------------------
- // Now, set up to copy the offscreen bit/pixmap to the screen
- //----------------------------------------------------------------------------------
- if(haveGW)
- SetGWorld(savePort, saveGDev);
- else
- SetPort((GrafPtr)savePort);
-
- if(inColor) {
- ForeColor(blackColor);
- BackColor(whiteColor);
- }
-
- //----------------------------------------------------------------------------------
- // now copy it to the onscreen port and restore our colors
- //----------------------------------------------------------------------------------
-
- CopyBits(offBits,
- &((GrafPtr)savePort)->portBits,
- &offRect,
- &rScale,
- srcCopy, nil);
-
- if(haveGW) {
- unlockPixels(pmHdl, (**hCDEF).qdVers);
- DisposeGWorld((**hCDEF).offPort);
- (**hCDEF).offPort = 0;
- }
-
- if(inColor)
- restoreColors(&saveFore, &saveBack);
-
- //----------------------------------------------------------------------------------
- // if we failed to get an inactive gray color, do it the old way
- //----------------------------------------------------------------------------------
-
- if(inactive & !haveGray) { // use the old way of drawing
- GetPenState(&savePen); // an inactive control
- PenMode(patBic);
- PenPat( (ConstPatternParam) "\xAA\x55\xAA\x55\xAA\x55\xAA\x55");
- PaintRect(&(**theCtl).contrlRect);
- SetPenState(&savePen);
- }
- SetClip(saveClip);
- DisposeRgn(saveClip);
- DisposeRgn(newClip);
- }
- }